home *** CD-ROM | disk | FTP | other *** search
- /*
- ••••••••••••••••••••••••
- Bitmap_PrepareToAnimate.c
- David Surovell
-
- Animating Bitmaps in GX: Under QuickDraw, blitting raster images into animating palette
- entries is achieved by setting the source bitmap’s color table flags appropriately.
- Under QuickDraw GX, the process is a bit more difficult, and involves cloning
- references to the destination viewDevice colorSet and colorProfile and inserting
- those references into the bitmap shape before drawing.
- ••••••••••••••••••••••••
- */
-
-
- #include <Types.h>
- #include <Memory.h>
-
- #include "graphics types.h"
- #include "graphics errors.h"
- #include "graphics routines.h"
-
- #include "graphics libraries.h"
-
-
-
- Boolean AttachShapeToDevice(
- gxViewDevice targetDevice,
- gxShape targetShape );
-
-
- Boolean AttachShapeToDevice(
- gxViewDevice targetDevice,
- gxShape targetShape )
- {
- gxBitmap bmInfo;
- gxColorSet targetDevCSet, targetDevCSetClone;
- gxColorProfile targetDevProfile, targetDevProfileClone;
- gxInk targetInk;
- gxTransferMode targetTransferMode;
-
- if ((targetDevice == nil) || (targetShape == nil))
- return false;
-
- if (GXGetShapeType( targetShape ) != gxBitmapType)
- return false;
-
- /* obtain references to the target viewDevice’s color set and profile */
- targetDevCSet = GetViewDeviceColorSet( targetDevice );
- targetDevProfile = GetViewDeviceColorProfile( targetDevice );
- if (targetDevCSet == nil)
- return false;
-
- /* clone the references */
- targetDevCSetClone = GXCloneColorSet( targetDevCSet );
- targetDevProfileClone = nil;
- if (targetDevProfile != nil)
- targetDevProfileClone = GXCloneColorProfile( targetDevProfile );
-
- /* assign the clones into the shape and its ink’s transfer mode */
- targetInk = GXGetShapeInk( targetShape );
- if (targetInk != nil)
- {
- // •••NOTE: this only works if the xferMode is copyMode
-
- (void)GXGetInkTransfer( targetInk, &targetTransferMode );
- targetTransferMode.set = targetDevCSetClone;
- targetTransferMode.profile = targetDevProfileClone;
- GXSetInkTransfer( targetInk, &targetTransferMode );
- }
-
- /* assign the clones into the shape and its ink’s transfer mode */
- GXGetBitmap( targetShape, &bmInfo, nil );
- bmInfo.set = targetDevCSet;
- bmInfo.profile = targetDevProfile;
- GXSetBitmap( targetShape, &bmInfo, nil );
-
- return true;
- }
-
-
-